import { Type } from 'class-transformer';
import { IsNotEmpty, ValidateNested } from 'class-validator';

export class EntryDto {
  id?: number;
  order: number;
  contentId?: number;
  description: string;
  startDate: string;
  endDate: string;
  title: string;
  subTitle: string;
  educationBackground: string;
  isHidden: number;
  list: string;
}

export class ContentDto {
  // resumeId?: number;
  displayname: string;
  iconKey: string;

  @IsNotEmpty({ message: 'sectionType必填!' })
  sectionType: string;

  @ValidateNested({ each: true })
  @Type(() => EntryDto)
  entries: EntryDto[];
}

export class PersonalDetailDto {
  id?: number;
  name: string;
  gender: number;
  birthDay: JSON;
  email: string;
  phoneNumber: string;
  workingYears: number;
  politicsStatus: number;
  maritalStatus: string;
  nationality: string;
  nativePlace: string;
  weightHeight: {
    height: string;
    weight: string;
  };
  detailsOrder: JSON;
  arrivalTime: number;
  expCity: string;
  expJob: string;
  expectedSalary: string;
  showAge: boolean;
  photoObj: {
    showPhoto: boolean;
    photo: string;
  };
  address: string;
}

export class CustomizationDto {
  template: string;
  templateId: number;
}

export class addResumeParamsDto {
  @IsNotEmpty({ message: 'personalDetails必填!' })
  @Type(() => PersonalDetailDto)
  personalDetails: PersonalDetailDto;

  // @ArrayMinSize(0)
  @ValidateNested({ each: true })
  @Type(() => ContentDto)
  content: ContentDto[];

  @IsNotEmpty({ message: 'customization必填!' })
  @Type(() => CustomizationDto)
  customization: CustomizationDto;
}

export class addCustomizationDto {
  @IsNotEmpty({ message: 'resumeId必填!' })
  resumeId: number;

  @IsNotEmpty({ message: 'customization必填!' })
  @Type(() => CustomizationDto)
  customization: CustomizationDto;
}

export class getResumeParamsDto {
  @IsNotEmpty({ message: 'id必填!' })
  id: number;
}

export class addContentParamsDto {
  @IsNotEmpty({ message: '简历id必填!' })
  resumeId: number;

  @IsNotEmpty({ message: 'sectionOrder必填!' })
  sectionOrder: Array<string>;

  @Type(() => ContentDto)
  content: ContentDto;
}

export class editContentParamsDto {
  @IsNotEmpty({ message: 'id必填!' })
  id: number;

  @IsNotEmpty({ message: '简历id必填!' })
  resumeId: number;

  displayname: string;
  iconKey: string;

  @IsNotEmpty({ message: 'sectionType必填!' })
  sectionType: string;
}

export class delContentParamsDto {
  @IsNotEmpty({ message: 'id必填!' })
  id: number;

  @IsNotEmpty({ message: '简历id必填!' })
  resumeId: number;

  // @IsNotEmpty({ message: 'sectionOrder必填!' })
  // sectionOrder: Array<string>;
}

export class ToggleHideEntryDto {
  @IsNotEmpty({ message: 'id必填!' })
  id: number;

  isHidden: boolean;
}

export class SortEntryDto {
  @IsNotEmpty({ message: 'contentId必填!' })
  contentId: number;

  @IsNotEmpty({ message: 'entryid必填!', each: true })
  newOrder: Array<string | number>;
}

export class ApplyTemplateDto {
  @IsNotEmpty({ message: 'id必填!' })
  id: number;

  @IsNotEmpty({ message: 'templateId必填!' })
  templateId: string;
}

class UpdatesDto {
  @IsNotEmpty({ message: '值必填!' })
  value: string;

  @IsNotEmpty({ message: '路径必填!' })
  path: string;
}

export class UpdateCustomizationDto {
  @IsNotEmpty({ message: 'id必填!' })
  id: number;

  @ValidateNested({ each: true })
  @Type(() => UpdatesDto)
  updates: UpdatesDto[];
}

export class EditSectionNameDto {
  @IsNotEmpty({ message: 'id必填!' })
  id: number;

  @IsNotEmpty({ message: '名称必填!' })
  displayName: string;

  iconKey: string;
}
